package com.villaday.idf.custom;


import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;

import com.villaday.idf.R;


/**
 * 等待加载框
 * Created by Administrator on 2017/3/3.
 */
public class LoadDialog extends DialogFragment {

    public static LoadDialog newInstance(String str) {
        LoadDialog loadingDialog = new LoadDialog();
        Bundle bundle = new Bundle();
        bundle.putString("str", str);
        loadingDialog.setArguments(bundle);
        return loadingDialog;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.dialog_loading, container);
        int phoneWidth = getActivity().getResources().getDisplayMetrics().widthPixels;
        JumpLoading jlLoading = (JumpLoading) inflate.findViewById(R.id.jl_loading);
        jlLoading.setLayoutParams(new LinearLayout.LayoutParams(phoneWidth / 3, phoneWidth / 8));
        jlLoading.startAnim();
        //点击对话框外不可取消
        getDialog().setCanceledOnTouchOutside(false);
        //设置对话框背景
        getDialog().getWindow().setBackgroundDrawableResource(R.drawable.shape_solid_trans);
        //取消标题显示
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        return inflate;
    }
}
